/**
 * @param {string[]} tokens
 * @return {number}
 */
var evalRPN = function(tokens) {
    let sign = {
        "+": 1,
        "-": 2,
        "*": 3,
        "/": 4,
    }
    let stack = [],
        item,
        char;

    for (let i = 0; i < tokens.length; i++) {
        item = tokens[i]
        char = sign[item]
        if (char !== undefined) {
            if (stack.length < 2) continue

            let second = stack.pop(),
                first = stack.pop(),
                result
            if (char === 1) {
                result = first - -second
            } else if (char === 2) {
                result = first - second
            } else if (char === 3) {
                result = first * second
            } else {
                result = ~~(first / second)
            }

            stack.push(result)
            continue
        }
        stack.push(item)
    }

    return +stack[0]
};